package com.lyq.mr.partition;


import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

//01	a00df6s	 kar	 120.196.100.99	 384	33	200
public class PartitionMapper extends Mapper<LongWritable, Text,Text,PartitionBean> {

    Text t = new Text();
    PartitionBean bean = new PartitionBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] fields = value.toString().split("\t");
        bean.setId(fields[0]);
        bean.setDeviceId(fields[1]);
        bean.setAppkey(fields[2]);
        bean.setIp(fields[3]);
        bean.setSelfDuration(Long.parseLong(fields[4]));
        bean.setThirdPartDuration(Long.parseLong(fields[5]));
        bean.setStatus(fields[6]);

        t.set(fields[2]);
        context.write(t,bean);

    }
}
